package com.example.demo0.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo0.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT u.*, r.role_name AS roleName " +
            "FROM users u " +
            "LEFT JOIN roles r ON u.role_id = r.id " +
            "WHERE u.id = #{id}")
    User selectUserWithRoleById(@Param("id") Long id);
}